def BubbleSort():
        n = len(arr)
        for i in range(len(arr)-1):
            for j in range(n-1):
                if arr[j]>arr[j+1]:
                    arr[j],arr[j+1]=arr[j+1],arr[j]
        n-=1
        return  arr

    def BubbleSort2():
        flag = True
        n = len(arr)
        while flag:
            flag = False
            for j in range(n-1):
                if arr[j]>arr[j+1]:
                    arr[j],arr[j+1]=arr[j+1],arr[j]
                    flag = True
            n-=1
        return arr


    arr=[4,5,7,1,2,3,9,2,8]
    print(BubbleSort())


